package com.efounder.form.comp.shoppingcar;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Color;
import android.os.AsyncTask;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import androidx.core.content.res.ResourcesCompat;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.OrientationHelper;
import android.util.Log;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.efounder.builder.base.data.DataSetEvent;
import com.efounder.builder.base.data.DataSetListener;
import com.efounder.builder.base.data.EFDataSet;
import com.efounder.builder.base.data.EFRowSet;
import com.efounder.builder.base.json.JSONUtil;
import com.efounder.constant.EnvironmentVariable;
import com.efounder.form.DMComponent;
import com.efounder.form.DataSetComponent;
import com.efounder.form.EFFormDataModel;
import com.efounder.form.application.ApplicationContainer;
import com.efounder.form.base.IComponent;
import com.efounder.form.builder.IScriptObject;
import com.efounder.form.comp.IUIComponent;
import com.efounder.form.comp.commodity.InterceptedRecyclerView;
import com.efounder.form.model.ColumnModel;
import com.efounder.form.model.JSONFormModel;
import com.efounder.form.model.ShoppingCarFormModel;
import com.efounder.form.util.FormCompUtil;
import com.efounder.frame.ViewSize;
import com.efounder.frame.activity.EFTransformFragmentActivity;
import com.efounder.frame.arcmenu.ArcMenu;
import com.efounder.frame.utils.Constants;
import com.efounder.frame.utils.EFAppAccountUtils;
import com.efounder.frame.utils.EFFrameUtils;
import com.efounder.message.manager.JFMessageManager;
import com.efounder.message.struct.IMStruct002;
import com.efounder.mobilecomps.R;
import com.efounder.util.AppContext;

import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by XinQing on 2016/9/14.
 */

public class ShoppingCar extends LinearLayout implements IComponent,IUIComponent,DMComponent,IScriptObject,DataSetListener{

    public ShoppingCar() {
//        super(AppContext.getInstance());
        super(EFFrameUtils.getCurrentActivity());
        init();
    }

    public ShoppingCar(Context context, EFRowSet rootRowSet) {
        super(context);
        init();
    }

    private InterceptedRecyclerView recyclerView;

    private String id;

    private int height;
    private int width;

    private int gap = 0;

    private ViewSize size = new ViewSize(0,0);

    private int percentWidth;
    private int percentHeight;

    private String originalText;

    private String dataSetID;
    private String dataSetColID;

    private String horizontalAlign;
    private String verticalAlign;

    private DataSetComponent dataSetComponent;
    private EFDataSet dataSet;
    private EFRowSet mainRowSet;

    private Map scriptObject = new HashMap();
    private Map scriptContext = new HashMap();

    private ColumnModel columnModel = new ColumnModel();

    private ShoppingCarFormModel shoppingCarFormModel;

    private ApplicationContainer applicationContainer;

    private ShoppingCarCategoryAdapter adapter;

    /**是否显示发送按钮**/
    private boolean showSendButton;
    /**是否显示清空按钮**/
    private boolean showClearButton;
    /**是否显示复选框**/
    private boolean showCheckBox;
    /**是否侧滑删除按钮**/
    private boolean showDeleteButton;
    /**是否显示分组标题**/
    private boolean showHeaderItem;

    private IUIComponent parentComp;

    private String headerLabel = "";

    @Override
    public void creationComplete() {
        //获取ShoppingCarFormModel
        applicationContainer = (ApplicationContainer)scriptContext.get("ApplicationContainer");
        if (applicationContainer == null) return;
        applicationContainer.putObject("ShoppingCarFormModel", dataSetComponent);
//        shoppingCarFormModel = (ShoppingCarFormModel)applicationContainer.getObject("ShoppingCarFormModel");
//        if (shoppingCarFormModel == null) {
//            shoppingCarFormModel = new ShoppingCarFormModel();
//            EFDataSet dataSet = new EFDataSet();
//            shoppingCarFormModel.getFormDataModel().setBillDataSet(dataSet);
//            applicationContainer.putObject("ShoppingCarFormModel", shoppingCarFormModel);
//            shoppingCarFormModel.creationComplete();
//        }
//        shoppingCarFormModel.insertDMComponent(this);
//        this.setLayoutSize();
        this.init();
    }

    @Override
    public void setLayout() {
        FormCompUtil.setLayoutSize(this);
    }

    private void init(){
        setOrientation(VERTICAL);
        //先清空一下
        removeAllViews();
        initPopButton();
        initRecyclerView();
        initBottomContainer();
    }

    public void dataChanged(EFDataSet dataSet) {
//        adapter = new ShoppingCarCategoryAdapter(this, (ShoppingCarFormModel) dataSetComponent);
//        recyclerView.setAdapter(adapter);
        adapter.reloadData((ShoppingCarFormModel) dataSetComponent);
    }

    private void initPopButton(){
        LinearLayout headerLayout = new LinearLayout(getContext());
        LayoutParams headerLayoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT);
        headerLayout.setLayoutParams(headerLayoutParams);
        headerLayout.setOrientation(LinearLayout.HORIZONTAL);
        headerLayout.setGravity(Gravity.CENTER_VERTICAL);

        //标题label
        TextView headerTextView = new TextView(getContext());
        LayoutParams headerTextLayoutParams = new LayoutParams(0,LayoutParams.WRAP_CONTENT);
        headerTextLayoutParams.weight = 1;
        headerTextView.setLayoutParams(headerTextLayoutParams);
        headerTextView.setText(headerLabel);
        headerTextView.setTextColor(Color.BLACK);
        headerTextView.setTextSize(16);
        headerLayout.addView(headerTextView);

        //弹出购物车按钮
        ImageView imageView = new ImageView(getContext());
        int width = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,50,getResources().getDisplayMetrics());
        int height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,30,getResources().getDisplayMetrics());
        LayoutParams layoutParams = new LayoutParams(width,height);
        layoutParams.bottomMargin = -5;
        layoutParams.rightMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,10,getResources().getDisplayMetrics());
        layoutParams.gravity = Gravity.RIGHT;
        imageView.setLayoutParams(layoutParams);
        imageView.setImageResource(R.drawable.icon_shopping);
        imageView.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                showDialog();
            }
        });
        headerLayout.addView(imageView);

        this.addView(headerLayout);
    }

    private void showDialog(){
        //自定义dialog
        AlertDialog.Builder builder = new AlertDialog.Builder(AppContext.getCurrentActivity());
        builder.setView(createContentView4Dialog());
        AlertDialog dialog = builder.create();
        dialog.setInverseBackgroundForced(true);
        dialog.setCanceledOnTouchOutside(false);
        dialog.setCancelable(true);
        dialog.show();
        dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog) {
                //先从父类删除，再添加
                ((ViewGroup)recyclerView.getParent()).removeView(recyclerView);
                ShoppingCar.this.addView(recyclerView);
            }
        });
    }

    private View createContentView4Dialog(){
        //contentView
        LinearLayout contentView = new LinearLayout(getContext());
        contentView.setOrientation(LinearLayout.VERTICAL);

        int width = getResources().getDisplayMetrics().widthPixels;
        int height = getResources().getDisplayMetrics().heightPixels/4*3;
        LayoutParams params = new LayoutParams(width,height);
        contentView.setLayoutParams(params);
        int paddingLeft = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,3,getResources().getDisplayMetrics());
        contentView.setPadding(paddingLeft,0,0,0);
        //先从父类删除，再添加
        ((ViewGroup)recyclerView.getParent()).removeView(recyclerView);
        contentView.addView(recyclerView);
        return contentView;
    }

    /**
     * 初始化RecyclerView
     */
    private void initRecyclerView(){
        recyclerView = new InterceptedRecyclerView(getContext());
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        layoutParams.weight = 1;
        recyclerView.setLayoutParams(layoutParams);
        LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
        //设置布局管理器
        recyclerView.setLayoutManager(layoutManager);
        //设置为垂直布局，这也是默认的
        layoutManager.setOrientation(OrientationHelper.VERTICAL);
        //设置分隔线
        recyclerView.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL_LIST));
        //设置增加或删除条目的动画
        recyclerView.setItemAnimator( new DefaultItemAnimator());
        //设置Adapter
        adapter = new ShoppingCarCategoryAdapter(this, (ShoppingCarFormModel) dataSetComponent);
        recyclerView.setAdapter(adapter);
//        adapter.notifyDataSetChanged();

        this.addView(recyclerView);
    }

    /***
     * 初始化发送和清空购物车按钮
     */
    private void initBottomContainer(){
        //container
        LinearLayout container = new LinearLayout(getContext());
        int containerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,3,getResources().getDisplayMetrics());
        container.setPadding(0,containerPadding,containerPadding,containerPadding);
        container.setOrientation(HORIZONTAL);
        int height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,36,getResources().getDisplayMetrics());
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, height);
        container.setLayoutParams(layoutParams);
        container.setGravity(Gravity.RIGHT|Gravity.CENTER_VERTICAL);
        if(!showClearButton&&!showSendButton){
            container.setVisibility(View.GONE);
        }
        //清空按钮
        Button clearButton = new Button(getContext());
        int buttonMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,5,getResources().getDisplayMetrics());
        LinearLayout.LayoutParams clearButtonParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        clearButtonParams.rightMargin = buttonMargin;
        clearButton.setLayoutParams(clearButtonParams);
        clearButton.setText("清空");
        if (showClearButton){
            clearButton.setVisibility(View.VISIBLE);
        }else {
            clearButton.setVisibility(View.GONE);
        }
        clearButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                AlertDialog.Builder builder = new AlertDialog.Builder(EFFrameUtils.getCurrentActivity());
                builder.setMessage("确定清空购物车？").setNegativeButton(R.string.common_text_cancel,null).setPositiveButton(R.string.common_text_confirm, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
//                        ShoppingCarCategoryAdapter adapter = (ShoppingCarCategoryAdapter) recyclerView.getAdapter();
                        adapter.clearShoppingCar();
                    }
                }).create().show();
            }
        });
        clearButton.setBackgroundResource(R.color.chat_red_dark);
        clearButton.setTextColor(ResourcesCompat.getColor(getResources(),R.color.ef_white,null));
        clearButton.setTextSize(15);
        clearButton.setPadding(0,0,0,0);

        container.addView(clearButton);
        //发送按钮
        Button sendButton = new Button(getContext());
        LinearLayout.LayoutParams sendButtonParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        sendButtonParams.rightMargin = buttonMargin;
        sendButton.setLayoutParams(sendButtonParams);
        sendButton.setText("发送");
        if (showSendButton){
            sendButton.setVisibility(View.VISIBLE);
        }else {
            sendButton.setVisibility(View.GONE);
        }
        sendButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                AlertDialog.Builder builder = new AlertDialog.Builder(EFFrameUtils.getCurrentActivity());
                builder.setMessage("确定发送？").setNegativeButton(R.string.common_text_cancel,null).setPositiveButton(R.string.common_text_confirm, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        //FIXME
//                        testGenerateJson();
//                        if (true) return;

                        //	{ "contentViewID" : "form1", "FormModel" : { },  "formName" : "发货确认单",  "formInfo" : "点击查看发货确认单。", "formImage" : "R.drawable.icon","formNameSub" : "发货确认单", "formID" : "fhqr"}
                        String json = "{ \"contentViewID\" : \"form1\", \"FormModel\" : { },  \"formName\" : \"发货确认单\",  \"formInfo\" : \"点击查看发货确认单详情。\",  \"formID\" : \"fhqr\"}";
//                        String json = "{ \"contentViewID\" : \"form1\", \"FormModel\" : { },  \"formName\" : \"差旅费报销\",  \"formInfo\" : \"点击查看差旅费报销单详情。\",  \"formID\" : \"fhqr\"}";
                        //{ "contentViewID" : "form1", "FormModel" : { },  "formName" : "发货确认单",  "formInfo" : "点击查看发货确认单。", "formImage" : "R.drawable.icon","formNameSub" : "发货确认单", "formID" : "fhqr"}

                        IMStruct002 imStruct002 = new IMStruct002();
                        try {
                            imStruct002.setBody(json.getBytes("UTF-8"));
                        } catch (UnsupportedEncodingException e) {
                            e.printStackTrace();
                        }
                        long time = new Date().getTime();
                        imStruct002.setTime(time);
                        imStruct002.setToUserType((byte) 0);
                        imStruct002.setMessageChildType((byte) 31);
                        //fromUserID toUserID
                        int toUserID = EFAppAccountUtils.getAppAccountID();
                        int toUserID2 = EFFrameUtils.getCurrentActivity().getIntent().getIntExtra("id",0);
                        imStruct002.setToUserId(toUserID);
                        imStruct002.setFromUserId(Integer.parseInt(EnvironmentVariable
                                .getProperty(Constants.CHAT_USER_ID)));
                        new AsyncTask<IMStruct002, Integer, String>() {

                            @Override
                            protected String doInBackground(IMStruct002... params) {
                                try {
                                    IMStruct002 struct002 = params[0];
                                    boolean b = JFMessageManager.getInstance().sendMessage(struct002);
                                    Log.i("--", "发送 ------ sendMessage:" + struct002.toString());
                                    //XXX 判断网络是否连接，如果没连接，直接加入未发送队列
                                    //if (!JFMessageManager.isChannelActive) {
                                    //	ChatMessageQueue.unsendMessageList.add(struct002);
                                    //}
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }

                                return null;
                            }

                            @Override
                            protected void onPostExecute(String s) {
                                super.onPostExecute(s);
                                gotoChat();
                            }
                        }.execute(imStruct002);


                    }
                }).create().show();
            }
        });
        sendButton.setBackgroundResource(R.color.chat_red_dark);
        sendButton.setTextColor(ResourcesCompat.getColor(getResources(),R.color.ef_white,null));
        sendButton.setTextSize(15);
        sendButton.setPadding(0,0,0,0);

        container.addView(sendButton);

        addView(container);
    }

//    Handler handler = new Handler(){
//        @Override
//        public void handleMessage(Message msg) {
//            super.handleMessage(msg);
//
//            //1.清空购物车
//            adapter.clearShoppingCar();
//            Log.i("---","--");
//            //2.finish activity
//            EFFrameUtils.getCurrentActivity().finish();
//            //3.跳转到聊天界面
//            Bundle bundle = EFFrameUtils.getCurrentActivity().getIntent().getExtras();
//            bundle.putInt(EFTransformFragmentActivity.EXTRA_TITLE_LEFT_VISIBILITY,View.VISIBLE);
//            bundle.putInt(EFTransformFragmentActivity.EXTRA_TITLE_RIGHT_VISIBILITY,View.INVISIBLE);
//            bundle.putString(EFTransformFragmentActivity.EXTRA_TITLE_NAME,bundle.getString("nickName"));
//            try {
//                EFFrameUtils.pushFragment((Class<? extends Fragment>) Class.forName("com.efounder.chat.publicnumber.PublicChatFragment")
//                        ,bundle);
//            } catch (ClassNotFoundException e) {
//                e.printStackTrace();
//            }
//
//        }
//    };
    public void gotoChat(){

//        handler.sendEmptyMessage(0);

        //1.清空购物车
        adapter.clearShoppingCar();
        Log.i("---","--");
        //2.finish activity
        EFFrameUtils.getCurrentActivity().finish();
        //3.跳转到聊天界面
        Bundle bundle = EFFrameUtils.getCurrentActivity().getIntent().getExtras();
        bundle.putInt(EFTransformFragmentActivity.EXTRA_TITLE_LEFT_VISIBILITY,View.VISIBLE);
        bundle.putInt(EFTransformFragmentActivity.EXTRA_TITLE_RIGHT_VISIBILITY,View.INVISIBLE);
        bundle.putString(EFTransformFragmentActivity.EXTRA_TITLE_NAME,bundle.getString("nickName"));
        try {
            EFFrameUtils.pushFragment((Class<? extends Fragment>) Class.forName(getResources()
                            .getString(R.string.PUBLIC_CHAT_FRAGMENT_PACKAGE_NAME)) ,bundle);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }



    private void testGenerateJson(){
        JSONFormModel jsonFormModel = new JSONFormModel();
        EFFormDataModel formDataModel = new EFFormDataModel();
        EFDataSet billDataSet = new EFDataSet();
        billDataSet.setTableName("xu_qiu_ji_hua_bill");
        //数据
        EFRowSet billRowSet = new EFRowSet();//IMStructUtil.getMsgId();
        billRowSet.putString("F_ID", System.currentTimeMillis() + "");//消息ID:F_ID
        billRowSet.putString("F_ZDR",EnvironmentVariable.getProperty(Constants.CHAT_USER_ID));//用户编号：F_ZDR
        billRowSet.putString("F_ZDRXM",EnvironmentVariable.getUserName());//用户名称：F_ZDRXM
        billRowSet.putString("F_XMBH","95");//项目编号：F_XMBH
        billRowSet.putString("F_XMMC","中铁十局济南项目部");//项目名称：F_XMMC

        billRowSet.putString("F_YWRQ",new SimpleDateFormat("").format(new Date()));//业务日期：F_YWRQ
        billRowSet.putString("F_NOTE","");//备注：F_NOTE


//        String json = FileUtils.readTextFile(EFAppAccountUtils.getAppAccountJsonPath() +"/xu_qiu_ji_hua.json");
//        EFRowSet billRowSet = JSONUtil.JSON2RowSet(json);

        billDataSet.addRowSet(billRowSet);
        formDataModel.setBillDataSet(billDataSet);
        jsonFormModel.setFormDataModel(formDataModel);

        new ShoppingUtils().mergeFormModel(jsonFormModel,getShoppingCarFormModel(),"shopping_car_data");
        String jsonMerge = JSONUtil.RowSet2JSON(jsonFormModel.getFormDataModel(),true);
        Log.i("jsonMerge","jsonMerge:-------=====" + jsonMerge);
    }

    /**
     * 关联列模型
     * @param columnModel
     */
    public void setColumnModel(ColumnModel columnModel){
        this.columnModel = columnModel;
    }

    public ColumnModel getColumnModel() {
        return columnModel;
    }

    @Override
    public DataSetComponent getDataSetComponent() {
        return dataSetComponent;
    }

    @Override
    public void setDataSetComponent(DataSetComponent dsc) {
        if (dataSetComponent != null)
            dataSetComponent.removeDMComponent(this);
        dataSetComponent = dsc;
        if (dataSetComponent != null)
            dataSetComponent.insertDMComponent(this);
    }

    public void setDataSetComponent(ShoppingCarFormModel dsc) {
        if (dataSetComponent != null)
            dataSetComponent.removeDMComponent(this);
        dataSetComponent = dsc;
        if (dataSetComponent != null)
            dataSetComponent.insertDMComponent(this);
    }

    /*
    * LinearLayout大小
    */
    public void setLayoutSize() {
        //设置控件宽高
        IUIComponent parent = (IUIComponent)this.getParent();
        int parentWidth = parent.getViewSize().getWidth();
        int parentHeight = parent.getViewSize().getHeight();

        int layoutWidth = parentWidth * this.percentWidth / 100;
        int layoutHeight = parentHeight * this.percentHeight / 100;

        layoutWidth = layoutWidth == 0 ? this.width : layoutWidth;
        layoutHeight = layoutHeight == 0 ? this.height : layoutHeight;

        this.size.setWidth(layoutWidth);
        this.size.setHeight(layoutHeight);

        LayoutParams layoutParams = new LayoutParams(layoutWidth, layoutHeight);
        layoutParams.rightMargin = parent.getGap();
        layoutParams.bottomMargin = parent.getGap();

        this.setLayoutParams(layoutParams);
    }

    public String getHorizontalAlign() {
        return horizontalAlign;
    }

    public void setHorizontalAlign(String horizontalAlign) {
        this.horizontalAlign = horizontalAlign;
    }

    public String getVerticalAlign() {
        return verticalAlign;
    }

    public void setVerticalAlign(String verticalAlign) {
        this.verticalAlign = verticalAlign;
    }

    @Override
    public void setDataSetID(String dataSetID) {
        this.dataSetID = dataSetID;
    }



    @Override
    public String getDataSetID() {
        return dataSetID;
    }

    @Override
    public void setDataSet(EFDataSet dataSet) {
        if ( this.dataSet != dataSet ) {
            if ( this.dataSet != null ) this.dataSet.removeDataSetListener(this);
            this.dataSet = dataSet;
            if ( this.dataSet != null ) this.dataSet.addDataSetListener(this);
            this.dataChanged(dataSet);
        }
    }

    @Override
    public EFDataSet getDataSet() {
        return dataSet;
    }

    @Override
    public EFRowSet getMainRowSet() {
        return mainRowSet;
    }

    @Override
    public void dataSetChanged(DataSetEvent event) {
        dataChanged(event.getDataSet());
    }

    @Override
    public String getID() {
        return id;
    }

    @Override
    public void setID(String id) {
        this.id = id;
    }

    @Override
    public int getGap() {
        return gap;
    }

    @Override
    public void setGap(int gap) {
        this.gap = gap;
    }

    @Override
    public void setCompWidth(int width) {
        this.width = width;
    }

    @Override
    public int getCompWidth(){
        return this.width;
    }

    @Override
    public void setCompHeight(int height) {
        this.height = height;
    }

    @Override
    public int getCompHeight() {
        return this.height;
    }

    @Override
    public int getPercentWidth() {
        return percentWidth;
    }

    @Override
    public void setPercentWidth(int percentW) {
        percentWidth = percentW;
    }

    @Override
    public int getPercentHeight() {
        return percentHeight;
    }

    @Override
    public void setPercentHeight(int percentH) {
        percentHeight = percentH;
    }

    @Override
    public ViewSize getViewSize() {
        return size;
    }

    @Override
    public void setViewSize(ViewSize size) {
        this.size = size;
    }

    public ShoppingCarFormModel getShoppingCarFormModel() {
        if(shoppingCarFormModel == null) {
            if (applicationContainer == null) return null;
            shoppingCarFormModel = (ShoppingCarFormModel)applicationContainer.getObject("ShoppingCarFormModel");
        }
        return shoppingCarFormModel;
    }

    public void setShoppingCarFormModel(ShoppingCarFormModel shoppingCarFormModel) {
        this.shoppingCarFormModel = shoppingCarFormModel;
    }

    @Override
    public Map getScriptObject() {
        return scriptObject;
    }

    @Override
    public void setScriptObject(Map scriptObject) {
        this.scriptObject = scriptObject;
    }

    @Override
    public String getEventScript(String key) {
        return (String) scriptObject.get(key);
    }

    @Override
    public void setEventScript(String key, String script) {
        scriptObject.put(key, script);
    }

    @Override
    public Map getScriptContext() {
        return scriptContext;
    }

    @Override
    public void setScriptContext(Map context) {
        scriptContext = context;
    }

    public ArcMenu getArcMenu(){
        ApplicationContainer applicationContainer = (ApplicationContainer)scriptContext.get("ApplicationContainer");
        if (applicationContainer == null) return null;
        return (ArcMenu) applicationContainer.getObject("arcMenu");
    }

    public boolean isShowClearButton() {
        return showClearButton;
    }

    public void setShowClearButton(boolean showClearButton) {
        this.showClearButton = showClearButton;
    }

    public boolean isShowSendButton() {
        return showSendButton;
    }

    public void setShowSendButton(boolean showSendButton) {
        this.showSendButton = showSendButton;
    }

    public boolean isShowCheckBox() {
        return showCheckBox;
    }

    public void setShowCheckBox(boolean showCheckBox) {
        this.showCheckBox = showCheckBox;
    }

    public boolean isShowDeleteButton() {
        return showDeleteButton;
    }

    public void setShowDeleteButton(boolean showDeleteButton) {
        this.showDeleteButton = showDeleteButton;
    }

    public boolean isShowHeaderItem() {
        return showHeaderItem;
    }

    public void setShowHeaderItem(boolean showHeaderItem) {
        this.showHeaderItem = showHeaderItem;
    }
    @Override
    public IUIComponent getParentComp() {
        return parentComp;
    }

    @Override
    public void setParentComp(IUIComponent comp) {
        parentComp = comp;
    }

    public String getHeaderLabel() {
        return headerLabel;
    }

    public void setHeaderLabel(String headerLabel) {
        this.headerLabel = headerLabel;
    }
}
